﻿using System;
using System.Windows;
using Silvery;
using Silvery.Scene;
using Silvery.Role.Standard;

namespace Sample03_Scene
{
    public class Sample_4 : GameRoot
    {
        NScene scene = new NScene();
        StandardRole hero;
        NPCPanel npcpanel = new NPCPanel();
        public Sample_4()
            :base(App.Current.RootVisual as FrameworkElement)
        {
            this.AddBaseObj(scene);
            scene.SceneStateChanged += new SceneStateChangeEventHandler(scene_SceneStateChanged);
            scene.SceneEnter(new SceneA(),false);
            
            hero = new StandardRole(new Uri("download/Sample_Role/PC002.zip", UriKind.Relative));
            scene.Hero = hero;
            hero.RoleName = "Nowpaper";
            hero.Position = new Point(253, 202);
            
            this.Children.Add(npcpanel);
            
        }

        void scene_SceneStateChanged(object sender, SceneState e)
        {
            if (e == SceneState.DataCompleted)
            {
                StandardNPC npc = new StandardNPC(new Uri("download/Sample_Role/NPC0001.zip", UriKind.Relative));
                npc.RoleName = "大天使引导";
                npc.Position = new Point(2000, 400);
                npc.StandardNpcClick += new StandardNpcClickEventHandler(npc_StandardNpcClick);
                scene.AddSceneObject(npc);
            }
        }

        void npc_StandardNpcClick(StandardNPC npc, object userstate)
        {
            npcpanel.Show();
        }

    }
}
